package com.example.content_android.me;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.DialogInterface;

import android.widget.Toast;

import com.example.content_android.LoginActivity;
import com.example.content_android.R;

public class MeHomeActivity extends Activity {
    AlertDialog.Builder builder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.me_home);

        builder = new AlertDialog.Builder(this);
//        匿名内部类点击事件
        Button settingButton = findViewById(R.id.setting);
        settingButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Creating dialog box
                AlertDialog alert = builder.create();
                alert.setMessage("请先登录系统！");
                alert.show();

            }
        });



        Button rankingButton = findViewById(R.id.ranking);
        rankingButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog alert = builder.create();
                alert.setMessage("请先登录系统！");
                alert.show();
//                builder.setMessage(R.string.login_alert) .setTitle(R.string.title_ranking);
//                AlertDialog alert = builder.create();
////                alert.setMessage("请先登录系统！");
//                alert.show();
            }
        });


        Button messageMeButton = findViewById(R.id.messageMe);
        messageMeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                AlertDialog alert = builder.create();
                alert.setMessage("请先登录系统！");
                alert.show();
//                builder.setTitle(R.string.title_messageMe);
////                //Setting message manually and performing action on button click
//                builder.setMessage("Do you want to close this application ?")
//                        .setCancelable(true)
//                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
//                            public void onClick(DialogInterface dialog, int id) {
//                                //finish（）会关闭应用
////                                finish();
//                                dialog.cancel();
//                                Toast.makeText(getApplicationContext(), "you choose yes action for alertbox", Toast.LENGTH_SHORT).show();
//                            }
//                        })
//                        .setNegativeButton("No", new DialogInterface.OnClickListener() {
//                            public void onClick(DialogInterface dialog, int id) {
//                                //  Action for 'NO' Button
//                                dialog.cancel();
//                                Toast.makeText(getApplicationContext(), "you choose no action for alertbox", Toast.LENGTH_SHORT).show();
//                            }
//                        });
//                //Creating dialog box
//                AlertDialog alert = builder.create();
//
//                alert.show();
            }
        });

// 获取控件id
        Button loginButton = findViewById(R.id.login);
        // 监听点击事件
        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MeHomeActivity.this, LoginActivity.class);
                startActivity(intent);

            }
        });






    }
}
